/**
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@use '@angular/material' as mat;

.expand-side-drawer {
  position: relative;
  top: 4%;
  left: 1%;
}

.drawer-container {
  height: 100%;
  background-color: var(--chat-drawer-container-background-color);
}

.drawer-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  @include mat.button-overrides(
    (
      filled-container-color: #89b4f8,
      filled-label-text-color: black,
    )
  );

  .mat-icon {
    width: 36px;
    height: 36px;
    color: #bdc1c6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .drawer-logo {
    margin-left: 9px;
    display: flex;
    align-items: center;

    img {
      margin-right: 9px;
    }

    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0.1px;
  }
}

.drawer-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  @include mat.button-overrides(
    (
      filled-container-color: #89b4f8,
      filled-label-text-color: black,
    )
  );

  .mat-icon {
    width: 36px;
    height: 36px;
    color: #bdc1c6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .drawer-logo {
    margin-left: 9px;
    display: flex;
    align-items: center;

    img {
      margin-right: 9px;
    }

    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0.1px;
  }
}

.chat-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.event-container {
  color: var(--chat-event-container-color);
}

.chat-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 12%;
  box-shadow: none;
  background-color: var(--chat-card-background-color);
}

.function-event-button .mdc-button__label {
  font-family: 'Google Sans Mono', monospace;
}

.loading-bar {
  width: 100px;
  margin: 15px;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
  margin-top: 16px;
}

.message-card {
  padding: 5px 20px;
  margin: 5px;
  border-radius: 20px;
  max-width: 80%;
  font-size: 14px;
  font-weight: 400;
  position: relative;
  display: inline-block;
}

.function-event-button {
  background-color: var(--chat-function-event-button-background-color);
  margin: 5px 5px 10px;
}

.function-event-button-highlight {
  background-color: var(
    --chat-function-event-button-highlight-background-color
  );
  border-color: var(
    --chat-function-event-button-highlight-border-color
  ) !important;
  color: var(--chat-function-event-button-highlight-color) !important;
}

.user-message {
  display: flex;
  justify-content: flex-end;
  align-items: center;

  .message-card {
    background-color: var(--chat-user-message-message-card-background-color);
    align-self: flex-end;
    color: var(--chat-user-message-message-card-color);
    box-shadow: none;
  }
}

.bot-message {
  display: flex;
  align-items: center;

  .message-card {
    background-color: var(--chat-bot-message-message-card-background-color);
    align-self: flex-start;
    color: var(--chat-bot-message-message-card-color);
    box-shadow: none;
  }
}

.bot-message:focus-within {
  .message-card {
    background-color: var(
      --chat-bot-message-focus-within-message-card-background-color
    );
    border: 1px solid
      var(--chat-bot-message-focus-within-message-card-border-color);
  }
}

.message-textarea {
  background-color: var(--chat-message-textarea-background-color);
  max-width: 100%;
  border: none;
  font-family: 'Google Sans', 'Helvetica Neue', sans-serif;
}

.message-textarea:focus {
  background-color: var(--chat-message-textarea-focus-background-color);
  outline: none;
}

.edit-message-buttons-container {
  display: flex;
  justify-content: flex-end;
}

.message-card .eval-compare-container {
  visibility: hidden;
  position: absolute;
  left: 10px;
  z-index: 10;
  background-color: var(--chat-eval-compare-container-background-color);
  overflow: hidden;
  border-radius: 20px;
  padding: 5px 20px;
  margin-bottom: 10px;
  font-size: 16px;

  .actual-result {
    border-right: 2px solid var(--chat-actual-result-border-right-color);
    padding-right: 8px;
    min-width: 350px;
    max-width: 350px;
  }

  .expected-result {
    padding-left: 12px;
    min-width: 350px;
    max-width: 350px;
  }
}

.message-card:hover .eval-compare-container {
  visibility: visible;
}

.actual-expected-compare-container {
  display: flex;
}

.score-threshold-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
  margin-top: 15px;
  font-size: 14px;
  font-weight: 600;
}

.eval-response-header {
  padding-bottom: 5px;
  border-bottom: 2px solid var(--chat-eval-response-header-border-bottom-color);
  font-style: italic;
  font-weight: 700;
}

.header-expected {
  color: var(--chat-header-expected-color);
}

.header-actual {
  color: var(--chat-header-actual-color);
}

.eval-case-edit-button {
  cursor: pointer;
  margin-left: 4px;
  margin-right: 4px;
}

.eval-pass {
  display: flex;
  color: var(--chat-eval-pass-color);
}

.eval-fail {
  display: flex;
  color: var(--chat-eval-fail-color);
}

.navigation-button-sidepanel {
  margin-left: auto;
  margin-right: 20px;
}

.fab-button {
  position: fixed;
  bottom: 200px;
  right: 100px;
  z-index: 1000;
}

.sidepanel-toggle {
  position: relative;
  top: 100px;
  z-index: 1000;
}

.side-drawer {
  background-color: var(--chat-side-drawer-background-color);
  color: var(--chat-side-drawer-color);
  border-radius: 0;
}

.file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
  margin-bottom: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--chat-file-item-background-color);
  padding: 5px;
  border-radius: 4px;
}

button {
  margin-left: 20px;
  margin-right: 20px;
}

.empty-state-container {
  color: var(--chat-empty-state-container-color);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  font-family: 'Google Sans', sans-serif;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 24px;
  font-size: 18px;

  pre.warning {
    color: var(--chat-warning-color);
  }

  pre.error {
    color: var(--chat-error-color);
  }
}

:host ::ng-deep .mat-mdc-unelevated-button:not(:disabled) {
  color: var(--chat-mat-mdc-unelevated-button-color);
  background-color: var(--chat-mat-mdc-unelevated-button-background-color);
}

:host ::ng-deep .mdc-linear-progress__buffer-dots {
  background: var(--chat-mdc-linear-progress-buffer-dots-background-color);
}

:host ::ng-deep .mat-mdc-select-arrow-wrapper {
  margin-left: 4px;
}

:host ::ng-deep .mat-mdc-text-field-wrapper {
  border: 1px solid var(--chat-mat-mdc-text-field-wrapper-border-color);
}

:host ::ng-deep .mdc-notched-outline__leading,
:host ::ng-deep .mdc-notched-outline__notch,
:host ::ng-deep .mdc-notched-outline__trailing {
  border: none;
}

:host ::ng-deep .mat-mdc-form-field-icon-suffix {
  padding: 0 10px 0 40px;
}

:host ::ng-deep .segment-key {
  color: var(--chat-segment-key-color) !important;
}

.mat-mdc-select-placeholder {
  margin-left: 20px;
}

.bottom-resize-handler {
  background: var(--chat-bottom-resize-handler-background-color);
  height: 5px;
  border-radius: 4px;
  position: absolute;
  display: block;
  width: 20%;
  left: 40%;
  top: 0;
  right: 0;
  z-index: 9999;
  cursor: ns-resize;
}

.trace-detail-container {
  position: relative;
  background-color: var(--chat-trace-detail-container-background-color);

  app-trace-event {
    padding-top: 8px;
  }
}

.new-session-button {
  margin-top: 0px;
  margin-left: 50px;
  width: 130px;
  height: 28px;
  font-size: 14px;
}

.app-select-container {
  width: 35%;
  background-color: #212123;
  height: 30px;
  display: flex;
  justify-content: space-between;
  padding-left: 20px;
  padding-right: 20px;
  border-radius: 10px;
  padding-top: 5px;
}

.app-select-container {
  @include mat.select-overrides(
    (
      placeholder-text-color: #8ab4f8,
      enabled-trigger-text-color: #8ab4f8,
      enabled-arrow-color: #8ab4f8,
    )
  );
}

.adk-checkbox {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin-bottom: 20px;
  margin-left: 20px;
}

.chat-toolbar {
  position: sticky;
  top: 0;
  height: 48px;
  background: var(--chat-toolbar-background-color);
  display: flex;
  align-items: center;
  z-index: 10;
}

.chat-toolbar.edit-mode {
  background: var(--chat-toolbar-edit-mode-background-color);
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.toolbar-session-text {
  color: var(--chat-toolbar-session-text-color);
  font-family: Roboto;
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
  line-height: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-left: 20px;
  padding-top: 4px;
  flex-shrink: 0;
}

.toolbar-session-id {
  color: var(--chat-toolbar-session-id-color);
  font-family: 'Google Sans Mono', monospace;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0.25px;
  margin-left: 5px;
  flex-shrink: 0;
}

.toolbar-icon {
  width: 24px;
  height: 24px;
  color: var(--chat-toolbar-icon-color);
  cursor: pointer;
  margin-right: 16px;
}

#toolbar-new-session-button {
  font-size: 14px;
  margin-right: 16px;
  color: var(--chat-toolbar-new-session-color);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.toolbar-sse-toggle {
  @include mat.slide-toggle-overrides(
    (
      label-text-size: 14px,
      label-text-color: var(--chat-toolbar-sse-toggle-label-text-color),
      unselected-track-color:
        var(--chat-toolbar-sse-toggle-unselected-track-color),
      unselected-focus-track-color:
        var(--chat-toolbar-sse-toggle-unselected-track-color),
      unselected-hover-track-color:
        var(--chat-toolbar-sse-toggle-unselected-track-color),
      unselected-handle-color:
        var(--chat-toolbar-sse-toggle-unselected-handle-color),
      unselected-focus-handle-color:
        var(--chat-toolbar-sse-toggle-unselected-handle-color),
      unselected-hover-handle-color:
        var(--chat-toolbar-sse-toggle-unselected-handle-color),
      selected-track-color: var(--chat-toolbar-sse-toggle-selected-track-color),
      selected-focus-track-color:
        var(--chat-toolbar-sse-toggle-selected-track-color),
      selected-hover-track-color:
        var(--chat-toolbar-sse-toggle-selected-track-color),
      selected-handle-color:
        var(--chat-toolbar-sse-toggle-selected-handle-color),
      selected-focus-handle-color:
        var(--chat-toolbar-sse-toggle-selected-handle-color),
      selected-hover-handle-color:
        var(--chat-toolbar-sse-toggle-selected-handle-color),
      track-height: 24px,
      track-width: 46px,
      track-outline-color: var(--chat-toolbar-sse-toggle-track-outline-color),
      with-icon-handle-size: 20px,
    )
  );
}

:host ::ng-deep pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-width: 100%;
}

.readonly-badge {
  color: var(--chat-readonly-badge-color);
  background-color: var(--chat-readonly-badge-background-color);
  border-radius: 4px;
  padding: 1px 6px;
  display: flex;
  align-items: center;
  margin-left: 8px;
  font-size: 12px;
  line-height: 16px;
  gap: 4px;
  white-space: nowrap;

  mat-icon {
    font-size: 14px;
    width: 14px;
    height: 14px;
    padding-top: 1px;
    flex-shrink: 0;
  }
}

.readonly-session-message {
  display: block;
  color: var(--chat-toolbar-session-text-color);
  margin-left: 1em;
  font-weight: 400;
  line-height: 16px;
  letter-spacing: 0.3px;
  flex-shrink: 1;
}

::ng-deep .mat-drawer-content {
  display: flex !important;
}

::ng-deep .mat-drawer {
  border-right: 1px solid var(--chat-mat-drawer-border-right-color) !important;
}

// Builder mode container and exit button
.builder-mode-container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--builder-container-background-color);
}

.builder-exit-button {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 8px;
}

.builder-mode-action-button {
  background-color: var(--builder-secondary-background-color) !important;
  color: var(--builder-text-tertiary-color) !important;
  border-radius: 50% !important;
  transition: all 0.2s ease !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border: 1px solid var(--builder-tool-item-border-color) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  &:hover {
    background-color: var(
      --builder-tool-item-hover-background-color
    ) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
  }

  &.active {
    background-color: var(--builder-button-primary-background-color) !important;
    color: white !important;
    border-color: var(--builder-button-primary-background-color) !important;
  }

  .mat-mdc-button-touch-target {
    display: none !important;
  }

  mat-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
  }
}

// Ensure canvas component takes full width in builder mode
app-canvas {
  width: 100% !important;
  height: 100% !important;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}

.build-mode-container {
  display: flex;
  width: 100%;
  height: 100%;
  background-color: var(--builder-container-background-color);
}

.build-left-panel,
.build-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--builder-tertiary-background-color);
  border: 1px solid var(--builder-border-color);
  margin: 10px;
  border-radius: 8px;
}

.build-panel-header {
  background-color: var(--builder-secondary-background-color);
  padding: 16px 20px;
  border-bottom: 1px solid var(--builder-border-color);
  border-radius: 8px 8px 0 0;

  h3 {
    margin: 0;
    color: var(--builder-text-primary-color);
    font-size: 16px;
    font-weight: 500;
    font-family: 'Google Sans', 'Helvetica Neue', sans-serif;
  }
}

.build-panel-content {
  flex: 1;
  padding: 20px;
  color: var(--builder-text-secondary-color);
  overflow-y: auto;

  p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
  }
}

.app-name-option,
.app-select {
  color: var(--builder-text-secondary-color);
  font-family: 'Google Sans Mono', monospace;
  font-style: normal;
  font-weight: 400;
  padding-left: unset;
}

.adk-web-developer-ui-disclaimer {
  padding-left: 4px;
  padding-bottom: 4px;
  font-size: 10px;
  color: var(--adk-web-text-color-light-gray);
}
